
import type { ResultHistroyType } from "@/type/menu";
import { http } from "./http";

export const selectBlance = async (id: string) => {
    return await http<moneyResult>({ method: 'get', url: '/api/select/money', data: { id: id } }) as unknown as moneyResult
}
export type moneyResult = {
    message: string
    money: number
}

export const verifyPassword = async (id: string, password: string) => {
    return await http<verifyPasswordResult>({ method: 'get', url: '/api/verify/password', data: { password: password, id: id } }) as unknown as verifyPasswordResult
}

export type verifyPasswordResult = {
    message: string
    data: boolean
}
export const updateMoney = async (account: string, money: number) => {
    return await http<updateMoneyResult>({ method: 'put', url: '/api/update/money', data: { account: account, money: money } }) as unknown as updateMoneyResult
}
export type updateMoneyResult = {
    message: string
    money: number
}
export const putTransferMoney = async (money: number, sender: string, receiver: string) => {
    return await http<updateMoneyResult>({ method: 'put', url: '/api/transfer/money', data: { money: money, sender: sender,receiver:receiver } }) as unknown as updateMoneyResult
}
export const putUpdatepassword = async(accoount:string,oldPassword:string,newPassword:string)=>{
    return await http({method:'post',url:'/api/update/password',data:{account:accoount,password:oldPassword,new_password:newPassword}}) as unknown as verifyPasswordResult
}
export const getHsitoryApi=async(account:string,pageNumber:number,pageSize:number)=>{
    return await http({method:'get',url:'api/get/history',data:{account:account,pageNumber:pageNumber,pageSize:pageSize}}) as unknown as ResultHistroyType
}
